#if !defined(MGACTIONIMPL_H_INCLUDED)
#define MGACTIONIMPL_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "MGAction.h"

class CMGActionImpl
{
protected:
	CMGActionImpl();
	~CMGActionImpl();

public:
	void Cleanup();

public:
	BOOL NoCommand(HWND hWnd, BOOL bRightButton, const POINT &ptTarget, BYTE bCatTarget = 0);
	BOOL DisplayContextMenu(HWND hWnd, const POINT &ptTarget);
	BOOL ExecuteCommand(HWND hWnd, WORD wID, LPCTSTR pszID, const POINT &ptTarget, BYTE bCatID = 0, BYTE bCatTarget = 0);
	BOOL ExecuteDblClk(HWND hWnd, enum MG::DoubleClickOption option,const POINT &ptTarget,  BYTE bCatTarget = 0);
	void UpdateStatusBar(LPCTSTR pszMessage);
	void UpdateStatusBarWheelCommand(LPCTSTR pszCommand, BOOL bUp);
	void Notify(enum MG::NotifyOption notification);
	void IdentifyTargetWindowClass(HWND hWnd);
	int CheckTargetValid(HWND hWnd);
	inline BOOL IsMGInAction() { return m_bMGInAction; }
	
public:
	void UpdateRegistry(BOOL bSaveAndValidate = TRUE);

	// Implemetations
protected:
	HWND GetMainWindow(HWND hActiveWnd = NULL);
	void ExecuteCommand(HWND hWnd, WORD wID1, ...);
	void ExecuteCommand(LPCTSTR pszID, ... );
	HWND FindStatusBarHandle();

private:
	HWND m_hStatusBar;
	HWND m_hMainWnd;

	DWORD m_dwThreadID;

	HCURSOR m_hCursorA;
	HCURSOR m_hCursorB;
	HCURSOR m_hCursorPrev;

	HICON m_hIcon;
	
	static LPCTSTR szValidWindowClasses[];
	UINT m_iValidWindowClass;

	BOOL m_bIdentifyTarget;
	
	BOOL m_bMGInAction;
	
	class XAutoActionFlag
	{
	public:
		XAutoActionFlag(BOOL &rbInAction) : m_rbInAction(rbInAction) { m_rbInAction = TRUE; }
		~XAutoActionFlag() { m_rbInAction = FALSE; }

	private:
		BOOL &m_rbInAction;
	};
};

#endif // !defined(MGACTIONIMPL_H_INCLUDED)
